<template>
  <nav-bar>
    <div slot="left" class="left" @click="back"><</div>
    <div slot="center" class="titles" >
      <div v-for="(item,index) in titles" :key="index" class="titles-item" :class='{active:index===currentIndex}' @click="titlesClick(index)">{{item}}</div>
    </div>
  </nav-bar>
</template>

<script>
import NavBar from 'components/common/navbar/NavBar'
export default {
  name: 'DetailNavBar',
  data() {
    return {
      titles: ['商品','参数','评论','推荐'],
      currentIndex: 0
    }
  },
  components: {
    NavBar
  },
  methods: {
    titlesClick(index) {
      this.currentIndex = index
      this.$emit('titlesClick',index)
    },
    back() {
      this.$router.back()
    }
  }
}
</script>

<style>
.left{
  font-size: 30px;
}
.titles{
  display: flex;
}
.titles-item{
  flex: 1;
}
.titles .active{
  color: var(--color-high-text);
}
</style>